const TerserPlugin = require('terser-webpack-plugin');
// 导入compression-webpack-plugin
const CompressionWebpackPlugin = require('compression-webpack-plugin');
// 定义压缩文件类型
const productionGzipExtensions = ['js', 'css'];
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = {
    lintOnSave: false,

    css: {
        loaderOptions: {
            stylus: {
                'resolve url': true,
                'import': [
                    './src/theme'
                ]
            }
        },
        extract: false,
        sourceMap: false
    },

    pluginOptions: {
        'cube-ui': {
            postCompile: true,
            theme: true
        }
    },

    devServer: {
        proxy: {
            '/site': {
                // target: 'http://www.xxyhl.cn',
                target: 'http://love.deyuelou.top',
                changeOrigin: true,
                pathRewrite: {
                    '^/site': ""
                }
            }
        }
    },

    publicPath: './',
    indexPath: 'love.html',
    outputDir: undefined,
    assetsDir: 'core',
    runtimeCompiler: undefined,
    productionSourceMap: false,
    parallel: undefined,

    configureWebpack: {
        optimization: {
            minimizer: [
                new TerserPlugin({
                    terserOptions: {
                        compress: {
                            drop_console: true
                        },
                        mangle: {
                            safari10: true,
                        },
                    },
                    sourceMap: false,
                })]
        },
        plugins: [
            // new BundleAnalyzerPlugin(),
            // new CompressionWebpackPlugin({
            //     filename: '[path].gz[query]',
            //     algorithm: 'gzip',
            //     test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
            //     threshold: 10240,
            //     minRatio: 0.8
            // })
        ]
    },

    pwa: {
        name: '心相依婚恋',
        themeColor: '#ec6786',
        msTileColor: '#FFFFFF'
    }
}
